class User < ActiveRecord::Base
	validates :name, presence: true
	validates :name, length: { in: 4..20 }
	validates :name, format: { with: /\A[a-zA-Z0-9]+\z/, message: 'only allows letters and numbers'}
	
	has_many :unblock
	
	def new_unblock(url)
		url.downcase!
		mt = %r{(.*//)?([^/:?#]+)[/:?#]?.*}.match(url)
		host = mt[2].split('.')
		if host.count>1
			host.shift if host[0]=='www'
			unblock.create host: host.join('.')
		end
	end
	
	def url
	end
end
